package com.example.design.controller;

import com.example.design.item.composite.ProductComposite;
import com.example.design.pojo.ProductItem;
import com.example.design.sercive.ProductItemService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.security.PublicKey;

@RestController
@RequestMapping("/product")
public class ProductController {

    @Resource
    private ProductItemService productItemService;

    // 获取所有商品类目
    @GetMapping("/fetchAllItems")
    public ProductComposite fetchAllItems() {
        return productItemService.findAllItems();
    }


    @PostMapping("/addItem")
    public ProductComposite addItem(@RequestBody ProductItem productItem) {
        return productItemService.addItem(productItem);
    }

    @PostMapping("/delItem")
    public ProductComposite delItem(@RequestBody ProductComposite productComposite) {
        return productItemService.delItem(productComposite);
    }

}
